package mapper;

import DO.WorkScoreDO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

@Mapper
public interface WorkStudentStateMapper {
    @Select("select state from work_student_state where work_id = #{workId} and user_id = #{userId}")
    Integer getStateById(Integer userId,Integer workId);

    // 修改学生状态表
    @Insert("insert into work_student_state (user_id, work_id, state, submissTime) VALUES (#{userId},#{workId}, 1,#{time})")
    void updateState(Integer userId, Integer workId, LocalDateTime time);

    // 插入学生成绩
    @Insert("insert into work_score (user_id, work_id, student_scores, create_time) VALUES (#{userId},#{workId},#{studentScores},#{createTime})")
    void saveScores(WorkScoreDO workScoreDO);

    // 查询学生成绩
    @Select("select student_scores from work_score where work_id = #{workId} and user_id = #{userId}")
    Double getScoresById(Integer userId,Integer workId);
}
